package com.example.demo.dao;

import com.example.demo.model.Userinfo;
import com.example.demo.model.vo.UserinfoVO;
import com.example.demo.service.UserService;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;

@Mapper
public interface UserMapper {
    //直接注解实现,就不写文件了
    @Insert("insert into userinfo(username,password) values(#{username},#{password})")
    int reg(Userinfo userinfo); //返回值是受影响的行数

    @Select("select*from userinfo where username=#{username}")//通过username查询对象
    Userinfo getUserByName(@Param("username")String username);

    //通过uid查询用户信息
    @Select("select*from userinfo where id=#{uid}")
    UserinfoVO getUserById(@Param("uid")Integer uid);
}
